﻿/*********************************************************************************
**                                                                              **
**  Copyright (C) 2024 LiLong                                                   **
**  This file is part of GnssLogs.                                              **
**                                                                              **
**  GnssLogs is free software: you can redistribute it and/or modify            **
**  it under the terms of the GNU Lesser General Public License as published by **
**  the Free Software Foundation, either version 3 of the License, or           **
**  (at your option) any later version.                                         **
**                                                                              **
**  GnssLogs is distributed in the hope that it will be useful,                 **
**  but WITHOUT ANY WARRANTY; without even the implied warranty of              **
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               **
**  GNU Lesser General Public License for more details.                         **
**                                                                              **
**  You should have received a copy of the GNU Lesser General Public License    **
**  along with GnssLogs.  If not, see <https://www.gnu.org/licenses/>.          **
**********************************************************************************/
#include <GnssLogs/GnssLogs.h>

#include <gtest/gtest.h>

#include <fstream>
#include <print>

inline void printSplit() { std::print("-----------------------------------------------------------------\n"); }

TEST(GlobalTest, bool)
{
    std::ifstream infile;
    infile.open(TEST_LOG_FILE, std::ios::in | std::ios::binary);
    if (!infile.is_open())
        EXPECT_TRUE(false);
    infile.seekg(0, std::ios::end);
    auto length = infile.tellg();
    infile.seekg(0, std::ios::beg);
    std::string data(length, '\0');
    infile.read(data.data(), length);
    infile.close();

    auto logs = GnssLogs::Decoder().decodeLogs<GnssLogs::GnssLogVariant>(data);
    for (const auto& log : logs)
    {
        std::visit(
            [](const auto& l)
            {
                printSplit();
                std::print("{}", l);
            },
            log);
    }
}

int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}